package com.example.hibernatevalidatebean.entity;

import com.example.hibernatevalidatebean.api.IXJValidate;
import org.hibernate.validator.constraints.CreditCardNumber;
import org.hibernate.validator.constraints.Length;
import org.hibernate.validator.constraints.Range;
import org.hibernate.validator.constraints.URL;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.RequestParam;
import sun.util.resources.CalendarData;

import javax.validation.constraints.*;
import java.util.Calendar;
import java.util.Date;
import java.util.concurrent.TimeUnit;

/**
 * @version 1.0
 * @program: hibernate-validate-bean
 * @packageName: com.example.hibernatevalidatebean.entity
 * @className User
 * @description: groups用于分组一些业务，方便配置
 * @author: xj
 * @create: 2021-01-18 16:03:41
 **/
public class User {

    @NotNull(groups = IXJValidate.class)
    String name;

//    @Null(groups = IXJValidate.class)
//    String chickname="0";

    //当hibernate校验时,空直接通过校验
//    @AssertTrue(groups = IXJValidate.class)
//    Boolean flag=false;

//    @AssertFalse(groups = IXJValidate.class)
//    Boolean windFlag=true;

//    @Min(value = 0,groups = IXJValidate.class)
//    int money=-1;

//    @Max(value = 0,groups = IXJValidate.class)
//    int tax=1;

//    @DecimalMin(value = "0",groups = IXJValidate.class)
//    String moneyStr="-1";

//    @DecimalMax(value = "0",groups = IXJValidate.class)
//    String taxStr="1";

    //目前@Size的校验器为删除了，这个注解不能用
//    @Size(max=10,min = 0,groups = IXJValidate.class)
//    int range2=-1;

//    @Digits(integer = 0, fraction = 10, groups = IXJValidate.class)
//    int range3 = -1;

//    @Past(groups = IXJValidate.class)
//    Date past = new Date(2022,1,1);

//    @Future(groups = IXJValidate.class)
//    Date future = new Date();

//    @Pattern(regexp = "^[1-9]\\d*$", groups = IXJValidate.class)
//    String pattern="abc";

//    @Email(regexp = "[\\w!#$%&'*+/=?^_`{|}~-]+(?:\\.[\\w!#$%&'*+/=?^_`{|}~-]+)*@(?:[\\w](?:[\\w-]*[\\w])?\\.)+[\\w](?:[\\w-]*[\\w])?", groups = IXJValidate.class)
//    String email="abc";

//    @Length(min = 0, max = 1, groups = IXJValidate.class)
//    String strlen = "abc";

//    @NotEmpty(groups = IXJValidate.class)
//    String strEmpty="";

//    @NotBlank(groups = IXJValidate.class)
//    String strEmpty2="";

//    //参数可以是数字字符串，也可以是数字
//    @Range(min = 0, max = 10, groups = IXJValidate.class)
//    String strRange = "-1";

//    @URL(protocol="http",host="127.0.0.1", port=80,regexp="[^\\s]*", flags={},groups = IXJValidate.class)
//    String strRange = "http://127.0.0.1:81/index.html";

//    //生产环境中的会用到的校验: 测试用的信用卡号：5105105105105100
//    @CreditCardNumber(groups = IXJValidate.class)
//    String strRange = "a";

}
